package com.example.employee.controller;

import com.example.common.domain.Result;
import com.example.employee.domain.dto.AdvertiseDTO;
import com.example.employee.domain.vo.AdvertiseVO;
import com.example.employee.service.AdvertisementService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "广告接口相关")
@Slf4j
@RestController
@RequestMapping("/employee/advertise")
@RequiredArgsConstructor
public class AdvertisementController {
    private final AdvertisementService advertisementService;

    /**
     * 获取广告
     * @param position
     * @return
     */
    @GetMapping("/list")
    public Result<List<AdvertiseVO>> getAdvertise(@RequestParam("distributionSite") Integer position) {
        List<AdvertiseVO> list=  advertisementService.getAdvertise(position);
        return Result.success(list);
    }
    /**
     * 添加广告
     * @param advertiseDTO
     * @return
     */
    @PostMapping
    public Result addAdvertise(@RequestBody @Validated AdvertiseDTO advertiseDTO) {
        advertisementService.addAdvertise(advertiseDTO);
        return Result.success();
    }
}